<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <body>
        <script>
            var removeElements = function (head, val) {
                let dummy = new ListNode(0, head)
                let cur = dummy.next
                let pre = dummy
                while (cur) {
                    if (cur.val == val) {
                        let next = cur.next
                        pre.next = next
                        cur = next
                    } else {
                        pre = cur
                        cur = cur.next
                    }
                }
                return dummy.next
            }
        </script>
    </body>
</html>
